<h1><?php echo __("Prêts et emprunts"); ?></h1>
<div class="demandes index">
	<div class="actions_horizontal">
		<ul>
			<li><?php echo $this->Html->link(__('Livres prêtés'), array('controller' => 'demandes', 'action' => 'index_livres_pretes')); ?></li>
			<li><?php echo $this->Html->link(__('Demandes de prêts'), array('controller' => 'demandes', 'action' => 'index_demandes_prets')); ?> </li>
			<li><?php echo $this->Html->link(__('Livres empruntés'), array('controller' => 'demandes', 'action' => 'index_livres_empruntes')); ?> </li>
			<li><?php echo $this->Html->link(__("Demandes d'emprunts"), array('controller' => 'demandes', 'action' => 'index_demandes_emprunts'),array( 'class' => 'selected')); ?> </li>
		</ul>
	</div>		
	<table cellpadding="0" cellspacing="0">
	<thead>
	<tr>
			<th><?php echo $this->Paginator->sort('statut_demande_id'); ?></th>
			<th><?php echo $this->Paginator->sort('demandeur_id'); ?></th>
			<th><?php echo $this->Paginator->sort('possesseur_id'); ?></th>
			<th><?php echo $this->Paginator->sort('exemplaire_id'); ?></th>
			<th><?php echo $this->Paginator->sort('date_demande', 'Date demande'); ?></th>
			<th><?php echo $this->Paginator->sort('date_reponse', 'Date réponse'); ?></th>
			<th class="actions"><?php echo __('Actions'); ?></th>
	</tr>
	</thead>
	<tbody>
	<?php foreach ($demandes as $demande): ?>
	<tr>
		<td>
			<?php echo $demande['StatutDemande']['label']; ?>
		</td>
		<td>
			<?php echo $this->Html->link($demande['Demandeur']['nom_utilisateur'], array('controller' => 'utilisateurs', 'action' => 'profil', $demande['Demandeur']['id'])); ?>
		</td>
		<td>
			<?php echo $this->Html->link($demande['Possesseur']['nom_utilisateur'], array('controller' => 'utilisateurs', 'action' => 'profil', $demande['Possesseur']['id'])); ?>
		</td>
		<td>
			<?php echo $this->Html->link($demande['Exemplaire']['Edition']['Livre']['titre'], array('controller' => 'editions', 'action' => 'view', $demande['Exemplaire']['Edition']['id'])); ?>
		</td>
		<td><?php echo h($demande['Demande']['date_demande']); ?>&nbsp;</td>
		<td><?php echo h($demande['Demande']['date_reponse']); ?>&nbsp;</td>
		<td class="actions">
			<?php echo $this->Form->postLink(__('Annuler'), array('action' => 'annuler_emprunt', $demande['Demande']['id']), array(), __('Are you sure you want to delete # %s?', $demande['Demande']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
	</tbody>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Page {:page} sur {:pages}, enregistrement {:current} sur un total de {:count}, amorce sur le n° {:start}, finissant sur le  n° {:end}')
	));
	?>	</p>
	<div class="paging">
	<?php
		echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
		echo $this->Paginator->numbers(array('separator' => ''));
		echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
	?>
	</div>
</div>
